<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .div{
            width: 200px;
            height: 200px;
            border: 1px solid black;
            background: url(./images/1.jpg);
            background-size: 100%;
        }
    </style>
</head>
<body>
    <div class="div"></div>
    <button>点点点点点</button>
    <script>
        var btn = document.querySelector("button")
        var getdiv = document.querySelector(".div")
        btn.onclick = function(){
            function xx(min,max){
                return parseInt(Math.random()*(max+1-min)+min)
            }
            var res = xx(1,6)
             getdiv.style.background = `url(./images/${res}.jpg)`
        }
    </script>
</body>
</html>